package com.xiaoran.robot;

import com.xiaoran.robot.config.MyWebsocketClient;
import org.java_websocket.client.WebSocketClient;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import java.net.URI;
import java.net.URISyntaxException;

@SpringBootApplication
@MapperScan("com.xiaoran.robot.mapper")
public class RobotApplication {
    @Value("${mirai.baseWsUrl}")
    private String baseWsUrl;
    public static void main(String[] args) {
        SpringApplication.run(RobotApplication.class, args);
    }

    @Bean
    public WebSocketClient webSocketClient() {
        try {
            WebSocketClient webSocketClient =  new MyWebsocketClient(new URI(baseWsUrl + "message?verifyKey=xiaoRanTop&qq=2767285912"));
            webSocketClient.connect();
            return webSocketClient;
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
        return null;
    }
}
